<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=emulateIE7" />
    <title>Coverage for I:\CourseRegistration\auth\views.py: 21%</title>
    <link rel="stylesheet" href="style.css" type="text/css">
    <script type="text/javascript" src="jquery.min.js"></script>
    <script type="text/javascript" src="jquery.hotkeys.js"></script>
    <script type="text/javascript" src="jquery.isonscreen.js"></script>
    <script type="text/javascript" src="coverage_html.js"></script>
    <script type="text/javascript">
        jQuery(document).ready(coverage.pyfile_ready);
    </script>
</head>
<body class="pyfile">
<div id="header">
    <div class="content">
        <h1>Coverage for <b>I:\CourseRegistration\auth\views.py</b> :
            <span class="pc_cov">21%</span>
        </h1>
        <img id="keyboard_icon" src="keybd_closed.png" alt="Show keyboard shortcuts" />
        <h2 class="stats">
            43 statements &nbsp;
            <span class="run shortkey_r button_toggle_run">9 run</span>
            <span class="mis show_mis shortkey_m button_toggle_mis">34 missing</span>
            <span class="exc show_exc shortkey_x button_toggle_exc">0 excluded</span>
        </h2>
    </div>
</div>
<div class="help_panel">
    <img id="panel_icon" src="keybd_open.png" alt="Hide keyboard shortcuts" />
    <p class="legend">Hot-keys on this page</p>
    <div>
    <p class="keyhelp">
        <span class="key">r</span>
        <span class="key">m</span>
        <span class="key">x</span>
        <span class="key">p</span> &nbsp; toggle line displays
    </p>
    <p class="keyhelp">
        <span class="key">j</span>
        <span class="key">k</span> &nbsp; next/prev highlighted chunk
    </p>
    <p class="keyhelp">
        <span class="key">0</span> &nbsp; (zero) top of page
    </p>
    <p class="keyhelp">
        <span class="key">1</span> &nbsp; (one) first highlighted chunk
    </p>
    </div>
</div>
<div id="source">
    <p id="t1" class="run"><span class="n"><a href="#t1">1</a></span><span class="t"><span class="key">from</span> <span class="op">.</span> <span class="key">import</span> <span class="nam">auth</span>&nbsp;</span><span class="r"></span></p>
    <p id="t2" class="run"><span class="n"><a href="#t2">2</a></span><span class="t"><span class="key">from</span> <span class="nam">auth</span><span class="op">.</span><span class="nam">forms</span> <span class="key">import</span> <span class="nam">LoginForm</span>&nbsp;</span><span class="r"></span></p>
    <p id="t3" class="run"><span class="n"><a href="#t3">3</a></span><span class="t"><span class="key">from</span> <span class="nam">flask</span> <span class="key">import</span> <span class="nam">render_template</span><span class="op">,</span> <span class="nam">redirect</span><span class="op">,</span> <span class="nam">request</span><span class="op">,</span> <span class="nam">url_for</span><span class="op">,</span> <span class="nam">flash</span>&nbsp;</span><span class="r"></span></p>
    <p id="t4" class="run"><span class="n"><a href="#t4">4</a></span><span class="t"><span class="key">from</span> <span class="nam">flask_login</span> <span class="key">import</span> <span class="nam">login_user</span><span class="op">,</span> <span class="nam">logout_user</span><span class="op">,</span> <span class="nam">login_required</span><span class="op">,</span> <span class="xx">\</span>&nbsp;</span><span class="r"></span></p>
    <p id="t5" class="pln"><span class="n"><a href="#t5">5</a></span><span class="t">    <span class="nam">current_user</span>&nbsp;</span><span class="r"></span></p>
    <p id="t6" class="run"><span class="n"><a href="#t6">6</a></span><span class="t"><span class="key">from</span> <span class="nam">models</span> <span class="key">import</span> <span class="nam">Student</span><span class="op">,</span> <span class="nam">Professor</span><span class="op">,</span> <span class="nam">Registrar</span>&nbsp;</span><span class="r"></span></p>
    <p id="t7" class="run"><span class="n"><a href="#t7">7</a></span><span class="t"><span class="key">from</span> <span class="nam">app</span> <span class="key">import</span> <span class="nam">db</span>&nbsp;</span><span class="r"></span></p>
    <p id="t8" class="pln"><span class="n"><a href="#t8">8</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t9" class="pln"><span class="n"><a href="#t9">9</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t10" class="run"><span class="n"><a href="#t10">10</a></span><span class="t"><span class="op">@</span><span class="nam">auth</span><span class="op">.</span><span class="nam">route</span><span class="op">(</span><span class="str">'/login'</span><span class="op">,</span> <span class="nam">methods</span><span class="op">=</span><span class="op">[</span><span class="str">'GET'</span><span class="op">,</span> <span class="str">'POST'</span><span class="op">]</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t11" class="pln"><span class="n"><a href="#t11">11</a></span><span class="t"><span class="key">def</span> <span class="nam">login</span><span class="op">(</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t12" class="mis show_mis"><span class="n"><a href="#t12">12</a></span><span class="t">    <span class="nam">form</span> <span class="op">=</span> <span class="nam">LoginForm</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t13" class="mis show_mis"><span class="n"><a href="#t13">13</a></span><span class="t">    <span class="key">if</span> <span class="nam">form</span><span class="op">.</span><span class="nam">validate_on_submit</span><span class="op">(</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t14" class="mis show_mis"><span class="n"><a href="#t14">14</a></span><span class="t">        <span class="nam">string_id</span> <span class="op">=</span> <span class="nam">str</span><span class="op">(</span><span class="nam">form</span><span class="op">.</span><span class="nam">id</span><span class="op">.</span><span class="nam">data</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t15" class="mis show_mis"><span class="n"><a href="#t15">15</a></span><span class="t">        <span class="key">if</span> <span class="nam">string_id</span><span class="op">.</span><span class="nam">startswith</span><span class="op">(</span><span class="str">"2"</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t16" class="mis show_mis"><span class="n"><a href="#t16">16</a></span><span class="t">            <span class="nam">user</span> <span class="op">=</span> <span class="nam">Student</span><span class="op">.</span><span class="nam">query</span><span class="op">.</span><span class="nam">filter_by</span><span class="op">(</span><span class="nam">student_id</span><span class="op">=</span><span class="nam">form</span><span class="op">.</span><span class="nam">id</span><span class="op">.</span><span class="nam">data</span><span class="op">)</span><span class="op">.</span><span class="nam">first</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t17" class="mis show_mis"><span class="n"><a href="#t17">17</a></span><span class="t">            <span class="key">if</span> <span class="nam">user</span> <span class="key">is</span> <span class="key">not</span> <span class="key">None</span> <span class="key">and</span> <span class="nam">user</span><span class="op">.</span><span class="nam">verify_password</span><span class="op">(</span><span class="nam">form</span><span class="op">.</span><span class="nam">password</span><span class="op">.</span><span class="nam">data</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t18" class="mis show_mis"><span class="n"><a href="#t18">18</a></span><span class="t">                <span class="nam">login_user</span><span class="op">(</span><span class="nam">user</span><span class="op">,</span> <span class="nam">form</span><span class="op">.</span><span class="nam">remember_me</span><span class="op">.</span><span class="nam">data</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t19" class="mis show_mis"><span class="n"><a href="#t19">19</a></span><span class="t">                <span class="nam">next</span> <span class="op">=</span> <span class="nam">request</span><span class="op">.</span><span class="nam">args</span><span class="op">.</span><span class="nam">get</span><span class="op">(</span><span class="str">'next'</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t20" class="mis show_mis"><span class="n"><a href="#t20">20</a></span><span class="t">                <span class="key">if</span> <span class="nam">next</span> <span class="key">is</span> <span class="key">None</span> <span class="key">or</span> <span class="key">not</span> <span class="nam">next</span><span class="op">.</span><span class="nam">startswith</span><span class="op">(</span><span class="str">'/'</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t21" class="mis show_mis"><span class="n"><a href="#t21">21</a></span><span class="t">                    <span class="nam">next</span> <span class="op">=</span> <span class="nam">url_for</span><span class="op">(</span><span class="str">'std.student_home'</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t22" class="mis show_mis"><span class="n"><a href="#t22">22</a></span><span class="t">                <span class="key">return</span> <span class="nam">redirect</span><span class="op">(</span><span class="nam">next</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t23" class="mis show_mis"><span class="n"><a href="#t23">23</a></span><span class="t">            <span class="nam">flash</span><span class="op">(</span><span class="str">'&#29992;&#25143;&#21517;&#25110;&#23494;&#30721;&#38169;&#35823;&#65281;'</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t24" class="pln"><span class="n"><a href="#t24">24</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t25" class="mis show_mis"><span class="n"><a href="#t25">25</a></span><span class="t">        <span class="key">elif</span> <span class="nam">string_id</span><span class="op">.</span><span class="nam">startswith</span><span class="op">(</span><span class="str">"5"</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t26" class="mis show_mis"><span class="n"><a href="#t26">26</a></span><span class="t">            <span class="nam">user</span> <span class="op">=</span> <span class="nam">Professor</span><span class="op">.</span><span class="nam">query</span><span class="op">.</span><span class="nam">filter_by</span><span class="op">(</span><span class="nam">professor_id</span><span class="op">=</span><span class="nam">form</span><span class="op">.</span><span class="nam">id</span><span class="op">.</span><span class="nam">data</span><span class="op">)</span><span class="op">.</span><span class="nam">first</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t27" class="mis show_mis"><span class="n"><a href="#t27">27</a></span><span class="t">            <span class="key">if</span> <span class="nam">user</span> <span class="key">is</span> <span class="key">not</span> <span class="key">None</span> <span class="key">and</span> <span class="nam">user</span><span class="op">.</span><span class="nam">verify_password</span><span class="op">(</span><span class="nam">form</span><span class="op">.</span><span class="nam">password</span><span class="op">.</span><span class="nam">data</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t28" class="mis show_mis"><span class="n"><a href="#t28">28</a></span><span class="t">                <span class="nam">login_user</span><span class="op">(</span><span class="nam">user</span><span class="op">,</span> <span class="nam">form</span><span class="op">.</span><span class="nam">remember_me</span><span class="op">.</span><span class="nam">data</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t29" class="mis show_mis"><span class="n"><a href="#t29">29</a></span><span class="t">                <span class="nam">next</span> <span class="op">=</span> <span class="nam">request</span><span class="op">.</span><span class="nam">args</span><span class="op">.</span><span class="nam">get</span><span class="op">(</span><span class="str">'next'</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t30" class="mis show_mis"><span class="n"><a href="#t30">30</a></span><span class="t">                <span class="key">if</span> <span class="nam">next</span> <span class="key">is</span> <span class="key">None</span> <span class="key">or</span> <span class="key">not</span> <span class="nam">next</span><span class="op">.</span><span class="nam">startswith</span><span class="op">(</span><span class="str">'/'</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t31" class="mis show_mis"><span class="n"><a href="#t31">31</a></span><span class="t">                    <span class="nam">next</span> <span class="op">=</span> <span class="nam">url_for</span><span class="op">(</span><span class="str">'pfs.professor_home'</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t32" class="mis show_mis"><span class="n"><a href="#t32">32</a></span><span class="t">                <span class="key">return</span> <span class="nam">redirect</span><span class="op">(</span><span class="nam">next</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t33" class="mis show_mis"><span class="n"><a href="#t33">33</a></span><span class="t">            <span class="nam">flash</span><span class="op">(</span><span class="str">'&#29992;&#25143;&#21517;&#25110;&#23494;&#30721;&#38169;&#35823;&#65281;'</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t34" class="pln"><span class="n"><a href="#t34">34</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t35" class="mis show_mis"><span class="n"><a href="#t35">35</a></span><span class="t">        <span class="key">elif</span> <span class="nam">string_id</span><span class="op">.</span><span class="nam">startswith</span><span class="op">(</span><span class="str">"1"</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t36" class="mis show_mis"><span class="n"><a href="#t36">36</a></span><span class="t">            <span class="nam">user</span> <span class="op">=</span> <span class="nam">Registrar</span><span class="op">.</span><span class="nam">query</span><span class="op">.</span><span class="nam">filter_by</span><span class="op">(</span><span class="nam">registrar_id</span><span class="op">=</span><span class="nam">form</span><span class="op">.</span><span class="nam">id</span><span class="op">.</span><span class="nam">data</span><span class="op">)</span><span class="op">.</span><span class="nam">first</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t37" class="mis show_mis"><span class="n"><a href="#t37">37</a></span><span class="t">            <span class="key">if</span> <span class="nam">user</span> <span class="key">is</span> <span class="key">not</span> <span class="key">None</span> <span class="key">and</span> <span class="nam">user</span><span class="op">.</span><span class="nam">verify_password</span><span class="op">(</span><span class="nam">form</span><span class="op">.</span><span class="nam">password</span><span class="op">.</span><span class="nam">data</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t38" class="mis show_mis"><span class="n"><a href="#t38">38</a></span><span class="t">                <span class="nam">login_user</span><span class="op">(</span><span class="nam">user</span><span class="op">,</span> <span class="nam">form</span><span class="op">.</span><span class="nam">remember_me</span><span class="op">.</span><span class="nam">data</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t39" class="mis show_mis"><span class="n"><a href="#t39">39</a></span><span class="t">                <span class="nam">next</span> <span class="op">=</span> <span class="nam">request</span><span class="op">.</span><span class="nam">args</span><span class="op">.</span><span class="nam">get</span><span class="op">(</span><span class="str">'next'</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t40" class="mis show_mis"><span class="n"><a href="#t40">40</a></span><span class="t">                <span class="key">if</span> <span class="nam">next</span> <span class="key">is</span> <span class="key">None</span> <span class="key">or</span> <span class="key">not</span> <span class="nam">next</span><span class="op">.</span><span class="nam">startswith</span><span class="op">(</span><span class="str">'/'</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t41" class="mis show_mis"><span class="n"><a href="#t41">41</a></span><span class="t">                    <span class="nam">next</span> <span class="op">=</span> <span class="nam">url_for</span><span class="op">(</span><span class="str">'rgs.registrar_home'</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t42" class="mis show_mis"><span class="n"><a href="#t42">42</a></span><span class="t">                <span class="key">return</span> <span class="nam">redirect</span><span class="op">(</span><span class="nam">next</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t43" class="mis show_mis"><span class="n"><a href="#t43">43</a></span><span class="t">            <span class="nam">flash</span><span class="op">(</span><span class="str">'&#29992;&#25143;&#21517;&#25110;&#23494;&#30721;&#38169;&#35823;&#65281;'</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t44" class="mis show_mis"><span class="n"><a href="#t44">44</a></span><span class="t">    <span class="key">return</span> <span class="nam">render_template</span><span class="op">(</span><span class="str">'auth/login.html'</span><span class="op">,</span> <span class="nam">form</span><span class="op">=</span><span class="nam">form</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t45" class="pln"><span class="n"><a href="#t45">45</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t46" class="pln"><span class="n"><a href="#t46">46</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t47" class="run"><span class="n"><a href="#t47">47</a></span><span class="t"><span class="op">@</span><span class="nam">auth</span><span class="op">.</span><span class="nam">route</span><span class="op">(</span><span class="str">'/logout'</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t48" class="run"><span class="n"><a href="#t48">48</a></span><span class="t"><span class="op">@</span><span class="nam">login_required</span>&nbsp;</span><span class="r"></span></p>
    <p id="t49" class="pln"><span class="n"><a href="#t49">49</a></span><span class="t"><span class="key">def</span> <span class="nam">logout</span><span class="op">(</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t50" class="mis show_mis"><span class="n"><a href="#t50">50</a></span><span class="t">    <span class="nam">logout_user</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t51" class="mis show_mis"><span class="n"><a href="#t51">51</a></span><span class="t">    <span class="nam">flash</span><span class="op">(</span><span class="str">'&#24744;&#24050;&#36864;&#20986;&#30331;&#24405;'</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t52" class="mis show_mis"><span class="n"><a href="#t52">52</a></span><span class="t">    <span class="key">return</span> <span class="nam">redirect</span><span class="op">(</span><span class="nam">url_for</span><span class="op">(</span><span class="str">'main.index'</span><span class="op">)</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
</div>
<div id="footer">
    <div class="content">
        <p>
            <a class="nav" href="index.html">&#xab; index</a> &nbsp; &nbsp; <a class="nav" href="https://coverage.readthedocs.io">coverage.py v5.1</a>,
            created at 2020-06-08 16:42
        </p>
    </div>
</div>
</body>
</html>
